package classics.Dichotomy;

/**
 * @Description EX62 寻找峰值
 *
 * @Author yangshunjie
 * @Date 2021/9/16
 */
public class findPeakElement {
    public static int findPeakElement(int[] nums) {
        if(nums.length==1){
            return 0;
        }
        int left = 0;
        int right = nums.length;
        while(left<right){
            int mid = left+right>>>1;
            if(mid==nums.length-1){
                return mid;
            }
            else if(nums[mid]>nums[mid+1]){
                right = mid;
            }else{
                left = mid+1;
            }
        }
        return left;
    }
}
